home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1995 March / PC Plus Super CD (Issue 101) (March 1995).iso / tclite / include / oopsconf.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-27  |  1.7 KB  |  67 lines

  1. #ifndef    OOPSCONFIG_H
  2. #define    OOPSCONFIG_H
  3.  
  4. inline unsigned mod_sizeof_short(unsigned i)
  5. {
  6.   return sizeof(short)&sizeof(short)-1
  7.          ? i%sizeof(short)
  8.          : i&sizeof(short)-1;
  9. }
  10.  
  11. inline unsigned mod_sizeof_int(unsigned i)
  12. {
  13.   return sizeof(int)&sizeof(int)-1
  14.          ? i%sizeof(int)
  15.          : i&sizeof(int)-1;
  16. }
  17.  
  18. inline unsigned mod_sizeof_long(unsigned i)
  19. {
  20.   return sizeof(long)&sizeof(long)-1
  21.          ? i%sizeof(long)
  22.          : i&sizeof(long)-1;
  23. }
  24.  
  25. inline unsigned mod_sizeof_float(unsigned i)
  26. {
  27.   return sizeof(float)&sizeof(float)-1
  28.          ? i%sizeof(float)
  29.          : i&sizeof(float)-1;
  30. }
  31.  
  32. inline unsigned mod_sizeof_double(unsigned i)
  33. {
  34.   return sizeof(double)&sizeof(double)-1
  35.          ? i%sizeof(double)
  36.          : i&sizeof(double)-1;
  37. }
  38.  
  39. inline unsigned mod_sizeof_ptr(unsigned i)
  40. {
  41.   return sizeof(void*)&sizeof(void*)-1
  42.          ? i%sizeof(void*)
  43.          : i&sizeof(void*)-1;
  44. }
  45.  
  46. // These are machine specific
  47. // and for the (8086) they are memory model specific
  48. // This configuration is for a small memory model
  49.  
  50. inline unsigned div_bitsize_char(unsigned i)    { return i >> 3; }
  51. inline unsigned mod_bitsize_char(unsigned i)    { return i & 7; }
  52. inline unsigned div_sizeof_short(unsigned i)    { return i >> 1; }
  53. inline unsigned div_sizeof_int(unsigned i)  { return i >> 1; }
  54. inline unsigned div_sizeof_long(unsigned i)    { return i >> 2; }
  55. inline unsigned div_sizeof_float(unsigned i)    { return i >> 2; }
  56. inline unsigned div_sizeof_double(unsigned i)    { return i >> 3; }
  57. inline unsigned div_sizeof_ptr(unsigned i)  { return i >> 1; }
  58.  
  59. // Pseudo-random number generator
  60. const long MAX_INT = 0x7fffffffL;
  61. inline long DRAW(unsigned long& x)
  62. {
  63.     return (x = x*1103515245L + 12345) & MAX_INT;
  64. }
  65.  
  66. #endif
  67.